import React from 'react';
import { connect } from "react-redux";
import { Card } from "@blueprintjs/core";
import TableWrapper from './Table';
import Insert from './Insert';
import Query from './Query';
import User from './User/index';

import './index.less';

class Middle extends React.PureComponent {
    constructor(props) {
        super(props);
        this.state = {
            moving: false
        }
    }

    render() {
        const {homeReduce} = this.props;
        const {menusSelected} = homeReduce;
        if (!menusSelected.menuType) return  null;
        let renderNode;
        if (menusSelected.menuType ==="insert") {
            renderNode =   <Insert />
        } else  if (menusSelected.menuType ==="user"){
            renderNode =   <User />
        } else if (menusSelected.menuType === "query") {
            renderNode = <Query />
        } else {
            renderNode =  <TableWrapper/>
        }
        return (
            <div className="middle-card">
                <Card interactive={false} elevation={3}>
                    {renderNode}
                </Card>
            </div>
        )
    }
}
const mapStateToProps = ({ homeReduce }) => ({ homeReduce });
export default connect(mapStateToProps)(Middle);